/*
Kakine
ActionScript Framework
Copyright © 2011, PUNY, LLC.

This file is part of KAKINE.

KAKINE is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

KAKINE is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with KAKINE.  If not, see <http://www.gnu.org/licenses/>.
*/ 
package com.puny.mvc.controllers
{
	import com.puny.mvc.BaseObject;
	import com.puny.xmlutils.XMLReader;

	/**
	 * $Revision: 443 $ <br/>
	 *  This defines an abstract class for controllers
	 *
	 * This is a chart that shows you the method order to be invoked.
	 * Each method can be overrode when you need.
	 * <img src="../../../../images/lifecycle.png"/>
	 *
	 * @example Here is a sample code for a controller class
	 * <listing>
	 * public class SampleController extends Controller {
	 *		public function SampleController() {
	 *			super("settings.xml");
	 * 		}
	 * 
	 * 		override protected function setup():void {
	 * 			//To access the loaded xml...
	 * 			var xml:XML = XMLReader.mxlDoc("settings.xml");
	 * 		}
	 * }
	 * </listing>
	 * This is a chart that shows you the method order to be invoked.
	 * Each method can be overrode when you need.
	 * <br/>
	 * <br/>
	 * loaded assets/<code>setup()</code>
	 * <br/>
	 * <br/>
	 * loaded assets &amp; added on stage/<code>beforeReady()</code>/
	 * <code>READY</code> event/
	 * <code>afterReady()</code>/
	 * <code>beforeOpen()</code>/
	 * <code>procedureOpen()</code>/
	 * <code>OPENED</code> event/
	 * <code>afterOpen()</code>/
	 * <code>beforeMainFrame()</code>/
	 * <code>procedureMainFrame()</code>/
	 * <code>afterMainFrame()</code>
	 * <br/>
	 * <br/>
	 * called <code>complete()</code> method/ 
	 * <code>beforeClose()</code>/
	 * <code>procedureClose()</code>/
	 * <code>afterClose()</code>/
	 * <code>COMPLETED</code> event/
	 * <code>beforeChildrenRemoved()</code>/
	 * <code>afterChildrenRemoved()</code>
	 * <br/>
	 */
	public class Controller extends BaseObject
	{
		private var _functions:Object = new Object();
		private var _objs:Array = new Array();
		public function Controller(filename:String=null)
		{
			super(filename);
//			boot(filename);
		}
		
		/**
		 * This method makes this controller running.
		 * 
		 * @param finename configuration file name.
		 * @private
		 */
		final override protected function boot(filename:Object=null):void {
			if (filename == null) {
				loaded();
			} else {
				var configrator:XMLReader = new XMLReader();
				configrator.setURL(filename as String);
				configrator.addEventListener(XMLReader.COMPLETED, loaded);
			}
		}
				
	}
}